home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK2.toast / Development Kits (Disc 2) / ScriptX / Draggable ScriptX Folders / utils / DTK / source / DIRIMP_SX / transtion.sx < prev    next >
Encoding:
Text File  |  1995-12-12  |  2.3 KB  |  88 lines  |  [TEXT/ttxt]

  1. -- *******************************************************
  2. -- *                                                     *
  3. -- * PrepareTransitionAction class                            *
  4. -- *                                                     *
  5. -- *******************************************************
  6.  
  7. class PrepareTransitionAction (Action)
  8.    instance variables
  9.         transitionClass
  10.         scoreTicker
  11.         duration
  12.         direction
  13.         scale
  14. end
  15.  
  16. method init self {class PrepareTransitionAction} #rest args #key transitionClass:(Wipe) \
  17.     duration:(5) direction:(@left) scale:(1) ->
  18. (
  19.     apply nextMethod self args
  20.     self.transitionClass := transitionClass
  21.     self.duration := duration
  22.     self.direction := direction
  23.     self.scale := scale
  24. )
  25.  
  26. method trigger self {class PrepareTransitionAction} theTarget thePlayer ->
  27. (
  28.  
  29.      -- Save old rate and stop the animation
  30.     
  31.     if thePlayer.scorePlayer.effectiveRate = 0 do
  32.         return self
  33.         
  34.     local ft := thePlayer.scorePlayer.scoreTicker
  35.     thePlayer.scorePlayer.scoreTickerRate := ft.rate
  36.     stop ft
  37.     
  38.     self.scoreTicker := ft
  39.     
  40.     -- Get the animation space and its parent
  41.     local ts := thePlayer.stage
  42.     local ps := ts.presentedBy
  43.     local myCompositor := ps.compositor
  44.     
  45.     -- Disable the compositor so that the removal of the space
  46.     -- is not seen by the compositor
  47.     myCompositor.enabled := false
  48.     
  49.     -- BUG!  What is presentedBy is undefined?
  50.     deleteOne ps ts
  51.     -- reenable the compositor.  Too soon?
  52.     myCompositor.enabled := true
  53.  
  54.         
  55.     local tp := new (self.transitionClass) duration:self.duration target:ts \
  56.         staticTarget:true direction:self.direction
  57.     
  58.     tp.scale := self.scale
  59.         
  60.     tp.masterClock := thePlayer.scorePlayer
  61.         
  62.     -- Add a callback to restart
  63.     AddTimeCallback tp restartAnimation thePlayer.scorePlayer undefined self.duration true
  64.  
  65.     thePlayer.scorePlayer.transitionPlayer := tp
  66.     
  67.     -- Hopefully place in the same z location, provided the user set a z on the stage
  68.     tp.z := ts.z
  69.     prepend ps tp
  70.     --tp.autoSplice := true
  71.     tp.direct := true
  72. )
  73.  
  74.  
  75. -- This function starts a transition that had been setup by a PrepareTransitionAction
  76. -- This function is used by the ScriptActions that are created in the ScorePlayerScoreTranslator
  77.  
  78. function ScorePlayerStartTransition self theTarget thePlayer ->
  79. (
  80.     local tp := thePlayer.scorePlayer.transitionPlayer
  81.     
  82.     if tp <> undefined do
  83.     (
  84.         playPrepare tp 1.0
  85.         play tp
  86.     )
  87. )
  88.